/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Engine2D.gui;

import Engine2D.geometry.Rectangle;
import Engine2D.geometry.Shape;
import Engine2D.graphics.GLColour;
import Engine2D.graphics.GLImage;
import Engine2D.graphics.font.GLFont;

/**
 *
 * @author Garys
 */
public class MessageBox extends AbstractComponent {
    /**
     * 
     */
    protected int x;
    /**
     * 
     */
    protected int y;
    /**
     * 
     */
    protected int width;
    /**
     * 
     */
    protected int height;
    private GLImage image;
    public Shape shape;
    private String message;
    /**
     * 
     */
    public GLColour colour;
    private GLFont font;
    
    /**
     * 
     * @param x
     * @param y
     * @param width
     * @param height
     * @param image
     * @param shape
     * @param message
     * @param colour
     * @param font
     */
    public MessageBox(int x, int y, int width, int height, GLImage image, Shape shape, String message, GLColour colour, GLFont font){
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.image = image;
        this.shape = shape;
        
        this.shape.setLocation(x, y);
        ((Rectangle)this.shape).setHeight(height);
        ((Rectangle)this.shape).setWidth(width);
        
        this.message = message;
        this.font = font;
        this.colour = colour;
    }

    /**
     * 
     * @param x
     * @param y
     */
    @Override
    public void render(int x, int y) {
        
        if (image!= null) {
            image.draw(this.x+x, this.y+y, 1f);
        }
        shape.render(this.x+x,this.y+y);
        
        
        shape.setX(this.x+x);
        
        shape.setY(this.y+y);
        shape.checkPoints();
        font.print(message, this.x+x, this.y+y, 1, colour);
        
        
    }

    /**
     * 
     * @param x
     * @param y
     */
    @Override
    public void setLocation(int x, int y) {
       
        
    }

    /**
     * 
     * @return
     */
    @Override
    public int getX() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * 
     * @return
     */
    @Override
    public int getY() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * 
     * @return
     */
    @Override
    public int getWidth() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * 
     * @return
     */
    @Override
    public int getHeight() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    
    
    /**
     * 
     * @param mouseButton
     * @param pressedX
     * @param pressedY
     */
    @Override
    public void mousePressed(int mouseButton, int pressedX, int pressedY) {
        if(x <= pressedX && (x+width)>= pressedX ) {
            if(y <= pressedY && (y+height) >= pressedY) {
            
                if (colour == GLColour.BLACK) {
                    colour = GLColour.GREEN;
                } else {
                colour = GLColour.BLACK;
                }
            }
        }
    }
    
}
